package cn.edu.scau.cmi.wujingxuan.composite.consistent;

import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.Label;
import javafx.scene.control.TextArea;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class ConsistentClient extends Application
{
	public static GridPane grid;

	public void start(Stage primaryStage)
	{
		VBox vbox = new VBox();
		HBox hbox = new HBox();
		GridPane grid = new GridPane();
		vbox.setPadding(new Insets(10)); // 内边距
		vbox.setSpacing(8); // 节点间距

		Label word = new Label("个人：	");
		TextArea driver = new TextArea("");

		ChoiceBox cb = new ChoiceBox(FXCollections.observableArrayList("Qian", "Sun", "Zhao"));
		cb.setValue("Qian");
		Button text = new Button("Say");

		text.setOnAction(e -> {
			String type = cb.getValue().toString();

			Organization wo = null;
			int len = 0;
			// String option="";
			if (type.equals("Zhao"))
			{
				wo = new Zhao();
			} else if (type.equals("Qian"))
			{
				wo = new Qian();
			} else if (type.equals("Sun"))
			{
				wo = new Sun();
			}
			driver.setText(wo.say());
		});
		grid.setVgap(50);
		grid.add(word, 0, 1);
		grid.add(text, 1, 3);
		grid.add(cb, 1, 1);
		hbox.getChildren().addAll(grid);
		vbox.getChildren().addAll(hbox, driver);

		Scene scene = new Scene(vbox, 800, 600);
		primaryStage.setScene(scene);
		primaryStage.setTitle("一致性组合模式");
		primaryStage.show();

	}

	public static void main(String[] args)
	{

		launch(args);
	}
}
